package impl;

import dao.DeptDao;
import jdbc.DBHelpers;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.SQLException;

/**
 * @classname:DeptDaoImpl
 * @description:
 * @author: Mr.Z
 * @date: 2020/12/28 11:51
 * @version: 0.1
 * @since:1.8
 */
public class DeptDaoImpl  implements DeptDao {

    @Override
    public int add() {
        int i = 0;
        Connection con = DBHelpers.getJdbcCon();
        String sql="insert into dept(deptno,dname,loc) values (70,'商业部','讷河')";
        try {
            PreparedStatement ps = con.prepareStatement(sql);
             i= ps.executeUpdate();
        } catch (SQLException e) {
            e.printStackTrace();
        }finally {
            DBHelpers.CloseResources(con);
        }

        return i;
    }


    public static void main(String[] args) {
        DeptDao deptDao = new DeptDaoImpl();
        int add = deptDao.add();
        System.out.println(add);
    }
}
